/**
 * ExtBIND
 * 
 * This file is included on every page.
 * 
 * @author		David Singer <david@ramaboo.com>
 */
Ext.BLANK_IMAGE_URL = '../ext/resources/images/default/s.gif';

// create namespace
Ext.namespace('ExtBIND');

String.prototype.toCamelCase = function() {
	return this.toString().replace(/([A-Z]+)/g, function(m,l) {
			return l.substr(0,1).toUpperCase() + l.toLowerCase().substr(1,l.length);
	}).replace(/[\-_\s](.)/g, function(m, l) {
		return l.toUpperCase();
	});
};

String.prototype.toProperCase = function() {
	return this.toLowerCase().replace(/\w+/g,function(s){
		return s.charAt(0).toUpperCase() + s.substr(1);
	});
}

Date.patterns = {
	ISO8601Long:"Y-m-d H:i:s",
	ISO8601Short:"Y-m-d",
	ShortDate: "d/m/Y",
	FullDateTime: "D d M Y H:i:s O",
	UniversalSortableDateTime: "Y-m-d H:i:s O"
};

/*
 * REMOVED IN Ext 3
// can not be Object.prototype or will cause error with combobox on FF3 
function isEmpty(v, allowBlank) {
	if (typeof v === 'object' || typeof v === 'function') {
		var i;
		for (i in v) {
			if (v.hasOwnProperty(i)) {
				return false;
			}
		}
		return true;
	} else {
		// not an object or function
		return v === null || v === undefined || (!allowBlank ? v === '' : false);
	}
};
Ext.isEmpty = isEmpty; // replace Ext.isEmpty with improved function
*/

// reusable error reader class for XML forms
Ext.form.XmlErrorReader = function(){
	Ext.form.XmlErrorReader.superclass.constructor.call(this, {
			record : 'field',
			success: '@success'
		}, [
			'id', 'msg'
		]
	);
};

Ext.extend(Ext.form.XmlErrorReader, Ext.data.XmlReader);